namespace Brjnk.GpxExplorer.Computing
{
    using System;
    using Brjnk.Common;
    using Brjnk.GpxExplorer.ViewModel;

    /// <summary>
    /// </summary>
    public class DistanceDeltaCalculator
    {
        public static void Calculate(ITrackPoint last, bool isLastInSegment, ITrackPoint point)
        {
            if (last != null)
            {
                Distance delta = (point.DistanceJoined.Value - last.DistanceJoined.Value);
                point.DistanceDeltaJoined = delta;
            }
            else
            {
                point.HasDurationDelta = false;
                point.DurationDeltaJoined = TrackPointAttributeValue<TimeSpan>.CreateUnset();
            }
        }
    }
}